# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-other
pkgname=polkit-qt
pkgver=0.114.0
pkgrel=2
pkgdesc="Qt wrapper around polkit-1 client libraries"
arch="all"
url="https://www.kde.org"
license="LGPL-2.1-only"
depends_dev="polkit-elogind-dev"
makedepends="$depends_dev
	cmake
	qt5-qtbase-dev
	qt6-qtbase-dev
	samurai
	"
_repo_url="https://invent.kde.org/libraries/polkit-qt-1.git"
source="https://download.kde.org/stable/polkit-qt-1/polkit-qt-1-$pkgver.tar.xz
	0001-$pkgname-Change-CMake-code-to-enable-building-against-Qt5-or-6.patch::https://invent.kde.org/libraries/polkit-qt-1/-/commit/fd1bc29594c6dee8b65c294c1c8595349f5cfdb2.patch
	"
subpackages="$pkgname-dev ${pkgname}5:_qt5 ${pkgname}6:_qt6"
builddir="$srcdir/polkit-qt-1-$pkgver"

replaces="polkit-qt-1<=0.114.0-r2"

build() {
	cmake -B build-qt5 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build-qt5

	cmake -B build-qt6 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DQT_MAJOR_VERSION=6
	cmake --build build-qt6
}

check() {
	ctest --test-dir build-qt5 --output-on-failure
	ctest --test-dir build-qt6 --output-on-failure

}

package() {
	DESTDIR="$pkgdir" cmake --install build-qt5
	DESTDIR="$pkgdir" cmake --install build-qt6
}

_qt5() {
	amove usr/lib/libpolkit-qt5*
}

_qt6() {
	amove usr/lib/libpolkit-qt6*
}

sha512sums="
4a16d9428d5ccc0107dcbd67c29ecba196424e555dc43d55cf2b6e0e7b72c99f894e9c994eaed85a9536010d67a19f20fe74f792c0d6b9ca0e05ce85f655f9a8  polkit-qt-1-0.114.0.tar.xz
8e781697268a48b46b6ada0d6fe035746ab7f30c0a110cd6a5f303c9df14a710ee19ae3a145901fd23535cdaf63a1530a5b0709afd9e9abb988186b81ce417a2  0001-polkit-qt-Change-CMake-code-to-enable-building-against-Qt5-or-6.patch
"
